<template>
  <pageTabelLayout>
    <template #pageHeader>
      <div class="search-form divClass" v-if="headerShow">
        <div>
          <a-form size="small" :model="queryData" layout="inline" v-if="pageData.nowPage == 1">
            <a-form-item label="类别名称" v-if="permissionStore.hasPermisson('pbzz.cx')">
              <a-input allow-clear :style="{ width: '200px' }" class="bacClass" placeholder=""
                v-model="pageData.dropDownData" @press-enter="huiche" />
            </a-form-item>
          </a-form>
        </div>
        <div class="my-tool-bar">
          <Toolbar :items="pageData.btnList" @add="addHandler" @del="deleteHandler" @select="selectHandler"
            @export="exportExcel" @import="importHandler" @excel="downloadHandler">
          </Toolbar>
        </div>
      </div>
      <div class="my-divisders">
        <a-divider orientation="center" v-if="pageData.nowPage == 1">
          <icon-double-up v-if="headerShow" @click="headerShow = false" :strokeWidth="2" :size="18" />
          <icon-double-down v-else @click="headerShow = true" :strokeWidth="2" :size="18" />
        </a-divider>
      </div>
    </template>

    <template #pageTabel>
      <a-tabs :lazy-load="true" :justify="true" @change="changeTabs">
        <template #extra>
          <Toolbar style="position: absolute;right: 0;" :items="tabBtnList" @import="importHandler"
            @excel="downloadHandler">
          </Toolbar>
        </template>
        <a-tab-pane title="坯布功能" key="1">
          <a-spin :loading="pageData.pageLoading" tip="加载中" dot style="height: 100%; width: 100%; z-index: 999">
            <div style="width: 100%; height: 100%">
              <encapsulation-agrid ref="table1Ref" :configaggrid="configTable1"></encapsulation-agrid>
            </div>
          </a-spin>
        </a-tab-pane>
        <a-tab-pane title="坯布组织" key="2">
          <a-spin :loading="pageData.pageLoading" tip="加载中" dot style="height: 100%; width: 100%; z-index: 999">
            <div style="width: 100%; height: 100%">
              <encapsulation-agrid ref="table2Ref" :configaggrid="configTable2"></encapsulation-agrid>
            </div>
          </a-spin>
        </a-tab-pane>
      </a-tabs>
    </template>
    <a-drawer style="z-index: 999" ok-text="保存" cancel-text="关闭" :drawer-style="{ zIndex: 9999 }" :width="400"
      :ok-loading="pageData.pageLoading" :visible="pageData.showAdd" unmountOnClose @ok="sideOk"
      @cancel="pageData.showAdd = false">
      <template #title>
        {{ pageData.sideTitle }}
      </template>
      <div>
        <a-form ref="formRef" layout="horizontal" :model="dataForm" v-if="pageData.nowPage == 0">
          <a-form-item label-col-flex="110px" label="坯布功能型号" field="greyInformation"
            :rules="[{ required: true, message: '坯布功能型号必填' }]" :validate-trigger="['change', 'blur']">
            <a-input class="bacClass" placeholder="" v-model="dataForm.greyInformation" @blur="inputBlur" />
          </a-form-item>
          <a-form-item label-col-flex="110px" label="坯布功能名称" field="greyInformationName"
            :rules="[{ required: true, message: '坯布功能名称必填' }]" :validate-trigger="['change', 'blur']">
            <a-input class="bacClass" placeholder="" v-model="dataForm.greyInformationName" />
          </a-form-item>

          <a-form-item label-col-flex="110px" label="备注" field="remark">
            <a-textarea class="bacClass" placeholder="" v-model="dataForm.remark" :max-length="400" allow-clear
              show-word-limit />
          </a-form-item>
        </a-form>
        <a-form ref="formRef" layout="horizontal" :model="dataForm" v-if="pageData.nowPage == 1">
          <a-form-item label-col-flex="80px" label="类别名称" field="categoryName"
            :rules="[{ required: true, message: '类别名称必填' }]" :validate-trigger="['change', 'blur']">
            <a-input class="bacClass" placeholder="" v-model="dataForm.categoryName" />
          </a-form-item>

          <a-form-item label-col-flex="80px" label="备注" field="remark">
            <!-- <a-input class="bacClass" v-model="dataForm.remark"/> -->
            <a-textarea class="bacClass" placeholder="" v-model="dataForm.remark" :max-length="400" allow-clear
              show-word-limit />
          </a-form-item>
        </a-form>
      </div>
    </a-drawer>
  </pageTabelLayout>
</template>

<script lang="ts">
import { post } from '@/api/http'
import { usePagination, useRowKey, useRowSelection, useTable, useTableColumn } from '@/hooks/table'
import { onMounted, reactive, ref } from 'vue'
import Toolbar from '@/components/Toolbar.vue'
import { Message, Modal } from '@arco-design/web-vue'
import { FormInstance } from '@arco-design/web-vue/es/form'
import { baseURL } from '../../../api/axios.config'
import axios from 'axios'
import filedownload from 'js-file-download'

import emitter from '@/hooks/useEventBus'
import { localeText } from '@/api/aggridZw'
import { pagingList } from '@/api/paging'
import usePermission from '@/store/modules/permission'
import { exportStyleExcel } from '@/api/Export2StyleExcel'
import { saveOrUpdateGridState as saveOrUpdateGridState01 } from '@/hooks/useGridState'
import { saveOrUpdateGridState as saveOrUpdateGridState02 } from '@/hooks/useGridState'

interface Firm {
  name: string
  id: number
}

interface Cloth {
  code: string
}

interface ClothInfo {
  id: any
  createTime: string | undefined
  remark: string | undefined
  greyInformation: string | undefined
  greyInformationName: string | undefined
  // category: string | undefined
  categoryName: string | undefined
  createName: string | undefined
  deleteState: number | undefined
}

export default {
  name: 'GermClothInfo',
  setup() {

    let cxbl = ''
    //查询
    const selectHandler = () => {
      pagination.page = 1
      cxbl = pageData.dropDownData
      doRefresh()
    }
    const table1Ref = ref<any>(null)
    const table2Ref = ref<any>(null)
    const tableColumns = [
      {
        title: '序号',
        key: 'serialNo',
        dataIndex: 'serialNo',
        width: 150,
      },
      {
        title: '坯布功能型号',
        key: 'greyInformation',
        dataIndex: 'greyInformation',
        width: 150,
      },
      {
        title: '坯布功能名称',
        key: 'greyInformationName',
        dataIndex: 'greyInformationName',
        width: 150,
      },
      {
        title: '备注',
        key: 'remark',
        dataIndex: 'remark',
        width: 150,
      },
      {
        title: '创建人',
        key: 'createName',
        dataIndex: 'createName',
        width: 150,
      },
      {
        title: '创建时间',
        key: 'createTime',
        dataIndex: 'createTime',
        width: 200,
      },
      {
        title: '最后修改人',
        key: 'updateName',
        dataIndex: 'updateName',
        width: 150,
      },
      {
        title: '最后修改时间',
        key: 'updateTime',
        dataIndex: 'updateTime',
        width: 150,
      },

      {
        title: '操作',
        key: 'id',
        slotName: 'act',
        width: 150,
        fixed: 'right',
      },
    ]
    const tableColumnsGn = [
      {
        title: '序号',
        key: 'category',
        dataIndex: 'category',
        width: 150,
      },
      {
        title: '类别名称',
        key: 'categoryName',
        dataIndex: 'categoryName',
        width: 150,
      },
      {
        title: '备注',
        key: 'remark',
        dataIndex: 'remark',
        width: 150,
      },
      {
        title: '创建人',
        key: 'createName',
        dataIndex: 'createName',
        width: 150,
      },
      {
        title: '创建时间',
        key: 'createTime',
        dataIndex: 'createTime',
        width: 200,
      },
      {
        title: '最后修改人',
        key: 'updateName',
        dataIndex: 'updateName',
        width: 150,
      },
      {
        title: '最后修改时间',
        key: 'updateTime',
        dataIndex: 'updateTime',
        width: 150,
      },
      {
        title: '操作',
        key: 'id',
        slotName: 'act1',
        width: 150,
        fixed: 'right',
      },
    ]
    let tc: any[] = tableColumns.map((o: any) => {
      let obj = {
        headerName: o.title,
        field: o.key,
        pinned: o['fixed'],
        tooltipField: o.key,
      }
      obj['width'] = 250
      if (o.slotName === 'act') {
        obj['resizable'] = false
        obj['filter'] = false
        obj['sortable'] = false
        obj['lockPosition'] = 'right'
        obj['width'] = 90
        obj['cellRenderer'] = {
          template: `
            <a-tag class="tagCss" @click="a" v-if="e">修改</a-tag>`,
          setup(props: any) {
            const a = () => {
              editHandler(props.params.data)
            }
            return {
              e: pageData.isEdit,
              a,
            }
          },
        }
      }

      return obj
    })
    tc.unshift({
      showRowGroup: 'hide_def',
      headerName: "",
      "checkboxSelection": true,
      "headerCheckboxSelection": true,
      "pinned": "left",
      "width": 50,
      resizable: false,
      filter: false,
      sortable: false,
      minWidth: 50,
      maxWidth: 50,
      lockPosition: "left",
    })
    let tc2: any[] = tableColumnsGn.map((o: any) => {
      let obj = {
        headerName: o.title,
        field: o.key,
        pinned: o['fixed'],
        width: 300,
        tooltipField: o.key,
      }
      if (o.slotName === 'act1') {
        obj['resizable'] = false
        obj['filter'] = false
        obj['sortable'] = false
        obj['lockPosition'] = 'right'
        obj['width'] = 90
        obj['cellRenderer'] = {
          // template: `<a-tag color="#ff7d00" class="gesture" @click="a">修改</a-tag>`,
          template: `
            <a-tag class="tagCss" @click="a" v-if="e">修改</a-tag>`,
          setup(props: any) {
            const a = () => {
              editHandler(props.params.data)
            }
            return {
              e: pageData.isEdit,
              a,
            }
          },
        }
      }

      return obj
    })
    tc2.unshift({
      showRowGroup: 'hide_def',
      headerName: "",
      "checkboxSelection": true,
      "headerCheckboxSelection": true,
      "pinned": "left",
      "width": 50,
      resizable: false,
      filter: false,
      sortable: false,
      minWidth: 50,
      maxWidth: 50,
      lockPosition: "left",
    })
    let configTable1 = {
      url: 'product/greyInformationData/selectPage', //接口路径
      queryData: {
        //接口参数
        deleteState: 0,
      },
      paginationShow: true, //分页是否显示
      invokeiIterface: true, //是否调用接
      rowMultiSelectWithClick: true, //点击行是否多选
      column: tc,
      fileName: 'GermClothInfo-1'
    }
    let configTable2 = {
      url: 'product/pdGreyInformationOrganization/selectpdGreyInformationPage', //接口路径
      queryData: {
        //接口参数
        deleteState: 0,
        categoryName: cxbl,
      },
      paginationShow: true, //分页是否显示
      invokeiIterface: true, //是否调用接
      rowMultiSelectWithClick: true, //点击行是否多选
      column: tc2,
      fileName: 'GermClothInfo-2'
    }

    function PageSize(val: any) {
      if (pageData.nowPage == 0) {
        pagination.page = val
      } else {
        paginations.page = val
      }
      doRefresh()
    }

    function change1(val: any) {
      if (pageData.nowPage == 0) {
        pagination.pageSize = val
      } else {
        paginations.pageSize = val
      }
      doRefresh()
    }

    const headerShow = ref<boolean>(true)
    let gc = reactive<any[]>([])
    let tableList1: any = []
    let tableList2: any = []

    function doRefresh() {
      if (pageData.nowPage == 0) {
        table1Ref.value.setQuery({ deleteState: 0, })
      } else {
        table2Ref.value.setQuery({
          deleteState: 0,
          categoryName: cxbl,
        })
      }
    }

    //判断当前页
    const changeTabs = (key: any) => {
      if (key == 1) {
        pageData.nowPage = 0
        doRefresh()
      } else {
        pageData.nowPage = 1
        doRefresh()
      }
      sessionStorage.setItem('qiehuamn', pageData.nowPage)
    }
    const { selectedRowKeys, onSelectionChange } = useRowSelection()
    const selectedRowKeysGn = useRowSelection()
    const pagination = usePagination(doRefresh)
    const paginations = usePagination(doRefresh)
    const table = useTable()
    const rowKey = useRowKey('id')
    const pageData = reactive<{
      gcList: Firm[]
      clothList: Cloth[]
      showAdd: boolean
      sideTitle: string
      nameList: any[]
      dropDownData: any
      pageLoading: boolean
      nowPage: any
      btnList: any[]
      isEdit: boolean
    }>({
      gcList: [],
      clothList: [],
      showAdd: false,
      sideTitle: '新增坯布功能组织',
      nameList: [],
      dropDownData: '',
      pageLoading: false,
      nowPage: 0,
      btnList: [],
      isEdit: false,
    })

    //下拉框得到焦点
    const focusSel = () => {
      selCxAll({ categoryName: '' })
    }
    //下拉数据
    const options = ref<any>(pageData.nameList)
    const loading = ref(false)
    const handleSearch = (value: any) => {
      if (value) {
        const ob = { categoryName: value }
        loading.value = true
        selCxAll(ob)
        options.value = pageData.nameList
        loading.value = false
      } else {
        options.value = []
      }
    }

    //下拉框查询
    function selCxAll(val: any) {
      post({
        url: 'product/pdGreyInformationOrganization/getFieldValue',
        data: val,
      }).then(({ data, code }: any) => {
        if (code === 200) {
          pageData.nameList = data
        } else {
          Message.error({
            content: '查询失败！',
            duration: 5000,
          })
        }
      })
    }

    onMounted(() => {
      // 切换tap到本页面执行的方法
      emitter.on('GermClothInfo', () => {
        if (pageData.nowPage == 0) {
          doRefresh()
        }
      })
    })
    const queryData = reactive({
      firm: '',
      clothType: '',
    })
    const addHandler = () => {
      pageData.showAdd = true
      pageData.sideTitle = '新增坯布功能组织'
      for (var key in dataForm) {
        if (key === 'id') {
          dataForm[key] = null
        } else if (key === 'deleteState') {
          dataForm[key] = 0
        } else {
          dataForm[key] = ''
        }
      }
    }
    // 表格准备事件
    const gridOption = ref()
    const colState = ref()
    const gridReady = (params: any) => {
      gridOption.value = params.api
      colState.value = params.columnApi
    }

    // 表格准备事件
    const gridOption2 = ref()
    const colState2 = ref()
    const gridReady2 = (params: any) => {
      gridOption2.value = params.api
      colState2.value = params.columnApi
    }

    const dataForm = reactive<ClothInfo>({
      id: null,
      createTime: '',
      remark: '',
      // category: '',
      categoryName: '',
      createName: '',
      deleteState: 0,
      greyInformationName: '',
      greyInformation: '',
    })
    const formRef = ref<FormInstance>()
    const sideOk = () => {
      formRef.value?.validate().then((err) => {
        if (!err) {
          pageData.pageLoading = true
          if (pageData.nowPage == 1) {
            for (const key in dataForm) {
              if (key == 'greyInformation' || key == 'greyInformationName') {
                dataForm[key] = undefined
              }
            }
            if (pageData.sideTitle === '新增坯布功能组织') {
              post({
                url: 'product/pdGreyInformationOrganization/insert',
                data: [dataForm],
              })
                .then((res: any) => {
                  if (res.code === 200) {
                    formRef.value?.resetFields()
                    pageData.showAdd = false

                    Message.success({
                      content: '新增成功',
                      duration: 5000,
                    })
                  } else {
                    Message.error({
                      content: res.message,
                      duration: 5000,
                    })
                  }
                  doRefresh()
                })
                .finally(() => {
                  pageData.pageLoading = false
                })
            } else {
              post({
                url: 'product/pdGreyInformationOrganization/update',
                data: [dataForm],
              })
                .then((res: any) => {
                  if (res.code === 200) {
                    formRef.value?.resetFields()
                    pageData.showAdd = false
                    Message.success({
                      content: '修改成功',
                      duration: 5000,
                    })
                  } else {
                    Message.error({
                      content: res.message,
                      duration: 5000,
                    })
                  }
                  doRefresh()
                })
                .finally(() => {
                  pageData.pageLoading = false
                })
            }
          } else {
            if (pageData.sideTitle === '新增坯布功能组织') {
              for (const key in dataForm) {
                if (key == 'category' || key == 'categoryName') {
                  dataForm[key] = undefined
                }
              }
              post({
                url: 'product/greyInformationData/insert',
                data: [dataForm],
              })
                .then((res: any) => {
                  if (res.code === 200) {
                    formRef.value?.resetFields()
                    pageData.showAdd = false

                    Message.success({
                      content: '新增成功',
                      duration: 5000,
                    })
                    doRefresh()
                  } else {
                    Message.error({
                      content: res.message,
                      duration: 5000,
                    })
                  }
                })
                .finally(() => {
                  pageData.pageLoading = false
                })
            } else {
              post({
                url: 'product/greyInformationData/update',
                data: [dataForm],
              })
                .then((res: any) => {
                  if (res.code === 200) {
                    formRef.value?.resetFields()
                    pageData.showAdd = false
                    Message.success({
                      content: '修改成功',
                      duration: 5000,
                    })
                    doRefresh()
                  } else {
                    Message.error({
                      content: res.message,
                      duration: 5000,
                    })
                  }
                })
                .finally(() => {
                  pageData.pageLoading = false
                })
            }
          }
        }
      })
    }
    const deleteHandler = () => {
      if (pageData.nowPage == 1) {
        if (table2Ref.value.getSelectedRows().length === 0) {
          Message.warning({
            content: '请先勾选数据',
            duration: 5000,
          })
          return
        }
        Modal.confirm({
          title: '系统提示',
          content: '确认删除选中的数据?',
          draggable: true,
          onOk() {
            pageData.pageLoading = true
            post({
              url: 'product/pdGreyInformationOrganization/deleteList',
              data: table2Ref.value.getSelectedRows().map((o: any) => {
                return o.id
              }),
            })
              .then(({ code, data }: any) => {
                if (code === 200) {
                  Message.success({
                    content: '删除成功',
                    duration: 5000,
                  })
                  pagination.page = 1
                  doRefresh()
                } else {
                  Message.error({
                    content: '修改失败',
                    duration: 5000,
                  })
                }
              })
              .finally(() => {
                pageData.pageLoading = false
              })
          },
        })
      } else {
        if (table1Ref.value.getSelectedRows().length === 0) {
          Message.warning({
            content: '请先勾选数据',
            duration: 5000,
          })
          return
        }
        Modal.confirm({
          title: '系统提示',
          content: '确认删除选中的数据?',
          draggable: true,
          onOk() {
            pageData.pageLoading = true
            post({
              url: 'product/greyInformationData/delete',
              data: table1Ref.value.getSelectedRows().map((o: any) => {
                return o.id
              }),
            })
              .then(({ code, data }: any) => {
                if (code === 200) {
                  Message.success({
                    content: '删除成功',
                    duration: 5000,
                  })
                  pagination.page = 1
                  doRefresh()
                } else {
                  Message.error({
                    content: '修改失败',
                    duration: 5000,
                  })
                }
              })
              .finally(() => {
                pageData.pageLoading = false
              })
          },
        })
      }
    }
    const editHandler = (record: ClothInfo) => {
      for (var key in record) {
        dataForm[key] = record[key]
      }
      pageData.sideTitle = '坯布功能组织'
      pageData.showAdd = true
    }

    //前端导出
    function exportExcel() {
      if (pageData.nowPage == 0 && table1Ref.value.getSelectedRows().length == 0) {
        Message.error('请先勾选需导出行数据！')
        return
      }
      if (pageData.nowPage == 1 && table2Ref.value.getSelectedRows().length == 0) {
        Message.error('请先勾选需导出行数据！')
        return
      }
      let header: any = []
      let filterVal: any = []
      let data: any = []
      if (pageData.nowPage == 1) {
        header = ['序号', '类别名称', '备注', '创建人', '创建时间', '最后修改人', '最后修改时间']
        filterVal = ['category', 'categoryName', 'remark', 'createName', 'createTime', 'updateName', 'updateTime']
        data = formatJson(filterVal, table2Ref.value.getSelectedRows());
        exportStyleExcel({ header, data, filename: "坯布组织.xlsx" })
      } else {
        header = ['序号', '坯布功能型号', '坯布功能名称', '备注', '创建人', '创建时间', '最后修改人', '最后修改时间']
        filterVal = ['serialNo', 'greyInformation', 'greyInformationName', 'remark', 'createName', 'createTime', 'updateName', 'updateTime']
        data = formatJson(filterVal, table1Ref.value.getSelectedRows());
        exportStyleExcel({ header, data, filename: "坯布功能.xlsx" })
      }
    }

    function formatJson(filterVal: any[], jsonData: any[]) {
      return jsonData.map(v => filterVal.map(j => {
        if (v[j]) {
          return v[j];
        } else {
          return '';
        }
      }))
    }

    //模板下载
    const downloadHandler = () => {
      if (pageData.nowPage == 1) {
        axios
          .get(baseURL + '/product/pdGreyInformationOrganization/uploadModel', {
            responseType: 'blob',
            headers: {
              token: sessionStorage.getItem('USER-TOKEN-KEY'),
            },
          })
          .then((res) => {
            if (res.status === 200) {
              filedownload(res.data, '坯布组织.xlsx')
            }
          })
      } else {
        axios
          .get(baseURL + '/product/greyInformationData/uploadModel', {
            responseType: 'blob',
            headers: {
              token: sessionStorage.getItem('USER-TOKEN-KEY'),
            },
          })
          .then((res) => {
            if (res.status === 200) {
              filedownload(res.data, '坯布功能.xlsx')
            }
          })
      }
    }
    //导入
    const importHandler = () => {
      const inputEle: HTMLInputElement = document.createElement('input')
      inputEle.type = 'file'
      inputEle.id = 'fileUploadExcel'
      inputEle.accept =
        'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel'
      inputEle.addEventListener('change', (e) => {
        const formData = new FormData()
        if (inputEle.files !== null) {
          formData.append('file', inputEle.files[0] || '')
        } else {
          Message.warning('未选择文件！')
          return
        }
        pageData.pageLoading = true
        if (pageData.nowPage == 1) {
          axios
            .post(baseURL + '/product/pdGreyInformationOrganization/importModelData', formData, {
              headers: {
                'Content-Type': 'multipart/form-data',
                token: sessionStorage.getItem('USER-TOKEN-KEY'),
              },
            })
            .then((result) => {
              if (result.data['code'] === 200) {
                Message.success('导入成功')
              } else {
                Message.error(result.data.message)
              }
            })
            .finally(() => {
              pageData.pageLoading = false
              doRefresh()
            })
        } else {
          axios
            .post(baseURL + '/product/greyInformationData/importModelData', formData, {
              headers: {
                'Content-Type': 'multipart/form-data',
                token: sessionStorage.getItem('USER-TOKEN-KEY'),
              },
            })
            .then((result) => {
              if (result.data['code'] === 200) {
                Message.success('导入成功')
              } else {
                Message.error(result.data.message)
              }
            })
            .finally(() => {
              pageData.pageLoading = false
              doRefresh()
            })
        }
      })
      inputEle.click()
    }
    const handleChange = (_data: any) => {
      if (pageData.nowPage == 0) {
        tableList1 = _data
      } else {
        tableList2 = _data
      }
      table.handleSuccess(_data)
    }
    const defaultColDef = {
      sortable: true,
      resizable: true,
      filter: true,
      // flex: 1
    }
    //input离开焦点 将小写转大写
    const inputBlur = () => {
      if (pageData.nowPage == 0) {
        dataForm.greyInformation = dataForm.greyInformation.toUpperCase()
      } else {
        // dataForm.category = dataForm.category.toUpperCase()
      }
    }
    const localeText1: any = ref(localeText)
    const huiche = () => {
      pagination.page = 1
      cxbl = pageData.dropDownData
      doRefresh()
    }

    const permissionStore = usePermission()
    const tabBtnList: any = ref([]);
    //szlb 纱支类别权限  sz纱支权限
    //判断是否是当前页
    if (pageData.nowPage == 0) {
      pageData.btnList = []
      pageData.isEdit = false
      if (permissionStore.hasPermisson('pbgn.cx')) {
        pageData.btnList.push('查询')
      }
      if (permissionStore.hasPermisson('pbgn.xz')) {
        pageData.btnList.push('新增')
      }
      if (permissionStore.hasPermisson('pbgn.sc')) {
        pageData.btnList.push('删除')
      }
      if (permissionStore.hasPermisson('pbgn.dc')) {
        pageData.btnList.push('导出')
      }
      if (permissionStore.hasPermisson('pbgn.dr')) {
        tabBtnList.value.push('导入')
      }
      if (permissionStore.hasPermisson('pbgn.mbxz')) {
        tabBtnList.value.push('模板下载')
      }
      if (permissionStore.hasPermisson('pbgn.xg')) {
        pageData.isEdit = true
      }
    } else {
      pageData.btnList = []
      pageData.isEdit = false
      if (permissionStore.hasPermisson('pbzz.cx')) {
        pageData.btnList.push('查询')
      }
      if (permissionStore.hasPermisson('pbzz.xz')) {
        pageData.btnList.push('新增')
      }
      if (permissionStore.hasPermisson('pbzz.sc')) {
        pageData.btnList.push('删除')
      }
      if (permissionStore.hasPermisson('pbzz.dc')) {
        pageData.btnList.push('导出')
      }
      if (permissionStore.hasPermisson('pbzz.dr')) {
        tabBtnList.value.push('导入')
      }
      if (permissionStore.hasPermisson('pbzz.mbxz')) {
        tabBtnList.value.push('模板下载')
      }
      if (permissionStore.hasPermisson('pbzz.xg')) {
        pageData.isEdit = true
      }
    }
    const pagingList1: any = ref(pagingList)
    return {
      colState2,
      tabBtnList,
      permissionStore,
      pagingList1,
      huiche,
      localeText1,
      inputBlur,
      defaultColDef,
      tc,
      tc2,
      PageSize,
      change1,
      deleteHandler,
      sideOk,
      formRef,
      dataForm,
      addHandler,
      selectedRowKeys,
      pagination,
      paginations,
      tableColumns,
      table,
      rowKey,
      pageData,
      queryData,
      gc,
      headerShow,
      s: selectedRowKeysGn.selectedRowKeys,
      tableColumnsGn,
      editHandler,
      options,
      loading,
      handleSearch,
      focusSel,
      selectHandler,
      exportExcel,
      importHandler,
      downloadHandler,
      changeTabs,
      handleChange,
      gridReady,
      gridReady2,
      table1Ref,
      configTable1,
      table2Ref,
      configTable2,
    }
  },
  components: {
    Toolbar,
  },
}
</script>
